#!/usr/bin/env python
# -*— coding: utf-8 -*-

from multiprocessing import Pool
import time, os

def test():
  print('pid=%d, ppid=%d'%(os.getpid(),os.getppid()))
  for i in range(3):
    print('---%d---'%i)
    time.sleep(1)
  return '张涵弈'

def test2(args): # 在主进程中执行
  print('--callback-- pid=%d'%os.getpid())
  print('--callback-- args=%s'%args)


def main():
  pool = Pool(3)
  pool.apply_async(func=test, callback=test2)
  while True:
    time.sleep(1)
    print('---主进程---- pid=%d'%os.getpid())

if __name__ == '__main__':
  main()

